/*
 * Copyright (c) 2019-2020, https://api.iot.10086.cn/(https://gitee.com/cmcc-iot-api/iot-card-open-application/).
 */
package cn.iot.card.open.sim.controller;

import cn.iot.card.open.pojo.page.LayuiPageFactory;
import cn.iot.card.open.pojo.page.LayuiPageInfo;
import cn.iot.card.open.sim.service.BusinessHandleResultService;
import cn.iot.card.open.util.CommonUtil;
import cn.stylefeng.roses.core.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 物联卡业务办理结果
 *
 * @author zhanlele
 * @date 20200320 15:04:56
 * @modify 20200320 zhanlele v1.1.2 创建
 * @since v1.1.2
 */
@Controller
@RequestMapping("/businessHandle")
public class BusinessHandleResultController {

    /**
     * 物联卡业务办理结果页面路劲前缀
     */
    private static final String PREFIX = "/modular/sim/business_handle/";

    @Autowired
    private BusinessHandleResultService businessHandleResultService;

    /**
     * 跳转业务办理结果页面
     *
     * @return 返回 string
     * @author zhanlele
     * @date 20200320 15:08:22
     * @modify 20200320 zhanlele v1.1.2 创建
     * @since v1.1.2
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "business_handle.html";
    }

    /**
     * 物联卡业务办理结果
     *
     * @param accountId 账户ID
     * @param jobId     业务办理流水号
     * @return 返回 layui page info
     * @throws Exception
     * @author zhanlele
     * @date 20200324 15:31:50
     * @modify 20200324 zhanlele v1.1.2 创建
     * @since v1.1.2
     */
    @RequestMapping("/queryHandleResult")
    @ResponseBody
    public LayuiPageInfo queryHandleResult(String accountId, String jobId) throws Exception {
        if (ToolUtil.isEmpty(accountId) && ToolUtil.isEmpty(jobId)) {
            return LayuiPageFactory.createEmptyPageInfo();
        }
        String transId = CommonUtil.generateTransId(accountId);
        return businessHandleResultService.queryHandleResult(accountId, transId, jobId);
    }
}
